<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>    
<%@ include file="/include/jsp/baseContent.jsp"%>
<link type="text/css" href="css/calendar/ui.all.css" rel="stylesheet" />
<link type="text/css" href="css/calendar/demos.css" rel="stylesheet" />    
<%
//type 이 failed 면 Goal Potential 이 없거나 정상 조회를 하지 못한 경우이다.
String type = request.getParameter("type");
%>
 <script type="text/javascript">
<!--//
var frameSize = 350 + (24 * <s:property value="labList.size" />);
parent.document.getElementById("hiddenframe1").style.height = frameSize;

function chkValue() {
	var returnVal = false;
	
	if(typeof(document.getElementsByName("laboratory_code")) == "object"){
	 	for(var i=0; i < document.getElementsByName("laboratory_code").length; i++){
			if(document.getElementsByName("laboratory_code")[i].checked) {
				//라디오버튼이 check 되있으면 true
				returnVal = true;	
			} 
		}
	}else{
		//라디오 버튼이 없으면 false
		returnVal = false;
	}
	return returnVal;
}

function submitPage(){
	
	var frmObj;
	
	if(chkValue()){
		
		//부모창에 있는 값을 가져와서 히든 객체에 셋팅
		if(typeof(parent.document.getElementsByName("career")) == "object"){
		 	for(var i=0; i < parent.document.getElementsByName("career").length; i++){
				if(parent.document.getElementsByName("career")[i].checked) {
					document.getElementById("goal_career").value = parent.document.getElementsByName("career")[i].value;	
				} 
			}
		}
		//부모창에 있는 값을 가져와서 히든 객체에 셋팅
		if(typeof(parent.document.getElementsByName("ability_code")) == "object"){
	 		document.getElementById("goal_ability_code").value = parent.document.getElementById("ability_code").value;	
		}
		
		frmObj = document.frm;
		frmObj.target = "_parent";
		frmObj.action = "/edu/insertGoalPotential.action";
		frmObj.method = "post";
		frmObj.submit();
	}else{
		alert("you have to check at least one of a laboratory lists.");
	}
}

function openPopup(url){
	
	var pop = window.open(url, '_blank', '');	
}

//-->
</script>	
<div style="margin:auto; text-align:center;">
	<!--// 컨텐츠 영역 -->
	<div id="mainContainer">
	<!-- //##### Contents START ############################# -->		
		<form id="frm" name="frm" method="post" >
		<input type="hidden" name="goal_career" id="goal_career">
		<input type="hidden" name="goal_ability_code" id="goal_ability_code">
		
		<div id="subtitle01" style="text-align:left; padding-left:5px;">
			<h5>Goal Potential</h5>
			<table border="1" style="width:80%; text-align:center;">
				<colgroup>
					<col width="10%">
					<col width="10%">
					<col width="10%">
					<col width="10%">
					<col width="10%">
					<col width="10%">
					<col width="10%">
				</colgroup>				
<%if("failed".equals(type)){%>
				<tr height="30">
					<td style="background:#fdcd8c;">Field</td>
					<td style="background:#fad296;">japanese</td>
					<td style="background:#fad296;">english</td>
					<td style="background:#fad296;">[not selected]</td>
					<td style="background:#fad296;">[not selected]</td>
					<td style="background:#fad296;">[not selected]</td>
					<td style="background:#fad296;">[not selected]</td>
				</tr>
				<tr height="30">
					<td style="background:#fdcd8c;">Goal</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				</tr>				
<%}else{%>
				<tr height="30">
					<td style="background:#fdcd8c;">Field</td>
					<td style="background:#fad296;">
						<input type="hidden" name="japanese" id="japanese" value="15">
						Japanese
					</td>
					<td style="background:#fad296;">
						<input type="hidden" name="english" id="english" value="16">
						English
					</td>
					<td style="background:#fad296;">
						<input type="hidden" name="major_code_1" id="major_code_1" value="<s:property value="resultDTO.req_classify_code_01"/>">
						<s:property value="resultDTO.req_classify_name_01"/>
					</td>
					<td style="background:#fad296;">
						<input type="hidden" name="major_code_2" id="major_code_2" value="<s:property value="resultDTO.req_classify_code_02"/>">
						<s:property value="resultDTO.req_classify_name_02"/>
					</td>
					<td style="background:#fad296;">
						<input type="hidden" name="major_code_3" id="major_code_3" value="<s:property value="resultDTO.req_classify_code_03"/>">
						<s:property value="resultDTO.req_classify_name_03"/>
					</td>
					<td style="background:#fad296;">
						<input type="hidden" name="major_code_4" id="major_code_4" value="<s:property value="resultDTO.req_classify_code_04"/>">
						<s:property value="resultDTO.req_classify_name_04"/>
					</td>
				</tr>	
				<tr height="30">
					<td style="background:#fdcd8c;">Goal</td>
					<%if("01".equals(request.getAttribute("career"))){	//master%>
					<td><input type="hidden" name="japanese_point" id="japanese_point" value="4">4</td>
					<td><input type="hidden" name="english_point" id="english_point" value="4">4</td>
					<td><input type="hidden" name="major_point_1" id="major_point_1" value="5">5</td>
					<td><input type="hidden" name="major_point_2" id="major_point_2" value="3">3</td>
					<td><input type="hidden" name="major_point_3" id="major_point_3" value="3">3</td>
					<td><input type="hidden" name="major_point_4" id="major_point_4" value="3">3</td>
					<%}else{	//doctoral & integration %>
					<td><input type="hidden" name="japanese_point" id="japanese_point" value="6">6</td>
					<td><input type="hidden" name="english_point" id="english_point" value="6">6</td>
					<td><input type="hidden" name="major_point_1" id="major_point_1" value="8">8</td>
					<td><input type="hidden" name="major_point_2" id="major_point_2" value="6">6</td>
					<td><input type="hidden" name="major_point_3" id="major_point_3" value="6">6</td>
					<td><input type="hidden" name="major_point_4" id="major_point_4" value="6">6</td>
					<%} %>					
				</tr>		
<%}%>
			</table>
		</div>
		<div id="subtitle02" style="text-align:left; padding-left:5px;">
<%if("failed".equals(type)){%>
			<h5 style="font-color:#f00;">First, Select Career & Ability.</h5>
<%}else{%>
			<h5 style="font-color:#f00;">Your major field is [ <s:property value="resultDTO.cc_name"/> ]<br>
			<input type="hidden" name="cc_code" id="cc_code" value="<s:property value="resultDTO.cc_code"/>">
			    Please check a laboratory of your interest theme</h5>			
<%}%>
			<table border="1" style="width:80%; text-align:center;">
				<tr>
					<td>&nbsp;</td>
					<td>lab. name</td>
					<td>Research theme</td>
					<td>Detail</td>
				</tr>
<%if("failed".equals(type)){%>
				<tr height="20">
					<td>&nbsp;</td>
					<td colspan="3">if you see a lab info, you have to select any Goal Career and Goal Ability.</td>
				</tr>
<%}else{%>
				<s:iterator value="labList">	
				<tr>
					<td><input type="radio" name="laboratory_code" value="<s:property value="laboratory_code"/>" /></td>
					<td><s:property value="laboratory_name"/></td>
					<td><s:property value="research_theme"/></td>
					<td><a href="javascript:openPopup('<s:property value="homepage"/>');">LINK</a></td>
				</tr>
				</s:iterator>
<%}%>
			</table>
		</div>
		<br><br>
		<input type="button" value="Submit" onclick="javascript:submitPage();">
		</form>				
	<!-- //##### Contents END ############################# -->
	</div>
	<!--// 컨텐츠 영역 -->
</div>